﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
	xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    xmlns:NControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
	xmlns:DControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data" 
	xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" 
	xmlns:Converters="clr-namespace:FU.Capstones.IMS.Web.Common.Converters;assembly=FU.Capstones.IMS.Web.Common" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.PartnerDetail" 
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.PartnerDetailViewModel"
    >
    
	
    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
        <Converters:IntegerToBoolConverter x:Key="IntegerToBoolConverter" />
    </UserControl.Resources>
	
	
    <telerik:RadBusyIndicator 
        BusyContent="{Binding Message, Mode=OneWay}" 
        IsBusy="{Binding ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}">
        <Grid x:Name="LayoutRoot"  Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <!--Title-->
            <Grid Grid.ColumnSpan="5">

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle" 
                        Style="{StaticResource TextBlockTitlePageStyle}"                   
                        Text="{StaticResource PartnerDetailPageTitle}"/>
            </Grid>
			
			<NControls:RadTabControl                
                Grid.Row="2"  Grid.Column="0" Grid.ColumnSpan="4"
                Background="Transparent"
                >
				<NControls:RadTabItem
                    Header="Thông tin đối tác"
                    Background="Transparent"
					IsSelected="True"
                    >
			
					<!--Data Field-->
		            <Grid x:Name="DataField" Grid.Row="3" Grid.Column="2" Background="Transparent">
		                <Grid.ColumnDefinitions>
		                    <ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
		                    <ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="*"/>
		                </Grid.ColumnDefinitions>
		                <Grid.RowDefinitions>
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                </Grid.RowDefinitions>

		                <!--Code-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="0"><Run Text="{StaticResource PartnerCodeLabelText}" /><Run Text=" "/><Run Foreground="Red" Text=" *" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="0"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.PartnerCode, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--Name-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="1"><Run Text="{StaticResource PartnerNameLabelText}" /><Run Text=" "/><Run Foreground="Red" Text=" *" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="1"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.CompanyName, Mode=TwoWay, ValidatesOnDataErrors=True}" Margin="5,8,0,6" />

		                <!--Address-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="2"><Run Text="{StaticResource AddressLabelText}" /><Run Text=" "/><Run Foreground="Red" Text=" *" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="2"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.Address, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--Phone number-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="3"><Run Text="{StaticResource OfficePhoneLabelText}" /><Run Text=" "/><Run Foreground="Red" Text=" *" /></TextBlock>            
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="3"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.OfficePhone, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--MobilePhone-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="4"><Run Text="{StaticResource MobileNumberLabelText}" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="4"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.MobilePhone, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--Fax-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="5"><Run Text="{StaticResource FaxLabelText}" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="5"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.Fax, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--Email-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="6"><Run Text="{StaticResource EmailLabelText}" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Grid.Column="2" Grid.Row="6"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.Email, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                    />

		                <!--Comment-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="7"><Run Text="{StaticResource BriefDescriptionLabelText}" /></TextBlock>
		                <TextBox 
		                    Style="{StaticResource TextBoxMultilineStyle}"
		                    Grid.Column="2" Grid.Row="7"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Partner.Description, Mode=TwoWay}"
		                    />


		                <!--Rating-->
		                <TextBlock
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Grid.Column="1" Grid.Row="8"><Run Text="{StaticResource RatingLabelText}" /></TextBlock>
		                <TControls:RadNumericUpDown                 
		                    Grid.Column="2" Grid.Row="8"
		                    Width="50" HorizontalAlignment="Left"
		                    Margin="5,2" IsInteger="True"
		                    Maximum="10" Minimum="0"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Value="{Binding Partner.Rating, Mode=TwoWay}"
		                    />

		                <StackPanel
		                    Grid.Row="9" Grid.Column="2"
		                    Orientation="Horizontal"
		                    >
		                    <CheckBox
		                        Style="{StaticResource CheckBoxNormalStyle}"
		                        IsChecked="{Binding Partner.IsSupplier, Mode=TwoWay}"
		                        IsThreeState="False"
                                IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                        />
		                    <TextBlock
		                        Style="{StaticResource TextBlockNormalStyle}"
		                        Text="Là nhà cung cấp?"
		                        />
		                </StackPanel>
								           
		            </Grid>
				</NControls:RadTabItem>
				
				<NControls:RadTabItem
					Header="Liên hệ"
					Background="Transparent"
					Visibility="{Binding Path=IsCreateNew, Mode=OneWay,Converter={StaticResource InverseBoolToVisibilityConverter}}"
					
					>
					<Grid Background="Transparent">
						<Grid.ColumnDefinitions>
		                    <ColumnDefinition Width="20"/>
							<ColumnDefinition Width="*"/>
		                    <ColumnDefinition Width="20"/>
							
		                </Grid.ColumnDefinitions>
		                <Grid.RowDefinitions>
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    
		                </Grid.RowDefinitions>
						<telerikGrid:RadGridView
							x:Name="GridView"
	                		Grid.Row="2" Grid.Column="1" 
	                		telerik:StyleManager.Theme="Office_Black"
	                		Style="{StaticResource RadGridViewNormal}"
	                		ItemsSource="{Binding Path=Partner.ContactCollection, Mode=TwoWay}"
							>
							
							<telerikGrid:RadGridView.Columns>

			                   	<telerikGrid:GridViewDataColumn 
			                        Header="Họ và tên"
			                        Width="200" HeaderTextAlignment="Center"
			                        DataMemberBinding="{Binding Path=FullName}"
			                    />

			                    <telerikGrid:GridViewDataColumn 
			                        Header="{StaticResource WarehousePhoneNoLabelText}"
			                        Width="200" HeaderTextAlignment="Center"
			                        DataMemberBinding="{Binding Path=MobilePhone}"
			                    />
								
								<telerikGrid:GridViewColumn Width="70">
			                        <telerikGrid:GridViewColumn.CellTemplate>
									    <DataTemplate>
			                                <Grid>
										        <HyperlinkButton 
											        Content="{StaticResource DeleteButtonText}"    
											        Command="{Binding DataSource.DeleteContactCommand, Source={StaticResource DataContextProxy}}"
											        CommandParameter="{Binding Path=ContactID}"
                                                    
                                                    IsEnabled ="{Binding Path=DataSource.CanEditOrAdd, Mode=OneWay, Source={StaticResource DataContextProxy}}" 
			                                        Visibility="{Binding Path=IsDelete, Converter={StaticResource InverseBoolToVisibilityConverter}}"
			                                    />
			                                    <TextBlock 
											        Text="{StaticResource DeletedLabelText}"
			                                        Style="{StaticResource TextBlockNormalStyle}"                                        
			                                        Visibility="{Binding Path=IsDelete, Converter={StaticResource BoolToVisibilityConverter}}"
			                                    />
			                                </Grid>
			                            </DataTemplate>
								    </telerikGrid:GridViewColumn.CellTemplate>
							    </telerikGrid:GridViewColumn>
								
	                   
	                		</telerikGrid:RadGridView.Columns>
						
						</telerikGrid:RadGridView>
						
				   		<Grid Grid.Row="3" Grid.Column="1" >	
						
				            <Controls:AddButtonControl HorizontalAlignment="Left"/>
							
				            <DControls:RadDataPager
				            	x:Name="DataPager"
				                Source="{Binding Path=Partner.ContactCollection, Mode=TwoWay}"
				                Style="{StaticResource DataPagerNormalStyle}"
								HorizontalAlignment="Right"
                                Visibility="{Binding Path=CanAddOrEdit, Mode=OneWay}"
			                />
						 </Grid>
						 
		            </Grid>
				
				</NControls:RadTabItem>
				
			</NControls:RadTabControl>

            <!--Message-->
            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
                />

            <!--Buttons-->
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="4">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
		
    </telerik:RadBusyIndicator>
</UserControl>
